home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / dev / gui / gtlayout.lha / Source / LTP_RenderCircle.c < prev    next >
C/C++ Source or Header  |  1999-01-02  |  1KB  |  75 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1999 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. #ifdef DO_TAPEDECK_KIND    /* Support code */
  17.  
  18. VOID
  19. LTP_RenderCircle(struct RastPort *RPort,LONG Left,LONG Top,LONG Radius,LONG AspectX,LONG AspectY)
  20. {
  21.     LONG x = 0,y = Radius,Delta = 2 * (1 - Radius),delta,Limit = 0,Length;
  22.  
  23.     while(y >= Limit)
  24.     {
  25.         if(Delta < 0)
  26.         {
  27.             delta = 2 * Delta + 2 * y - 1;
  28.  
  29.             if(delta > 0)
  30.             {
  31.                 x = x + 1;
  32.                 y = y - 1;
  33.                 Delta = Delta + 2 * x - 2 * y + 2;
  34.             }
  35.             else
  36.             {
  37.                 x = x + 1;
  38.                 Delta = Delta + 2 * x + 1;
  39.             }
  40.         }
  41.         else
  42.         {
  43.             if(Delta > 0)
  44.             {
  45.                 delta = 2 * Delta - 2 * x - 1;
  46.  
  47.                 if(delta > 0)
  48.                 {
  49.                     y = y - 1;
  50.                     Delta = Delta - 2 * y + 1;
  51.                 }
  52.                 else
  53.                 {
  54.                     x = x + 1;
  55.                     y = y - 1;
  56.                     Delta = Delta + 2 * x - 2 * y + 2;
  57.                 }
  58.             }
  59.             else
  60.             {
  61.                 x = x + 1;
  62.                 y = y - 1;
  63.                 Delta = Delta + 2 * x - 2 * y + 2;
  64.             }
  65.         }
  66.  
  67.         Length = (x * AspectY) / AspectX;
  68.  
  69.         LTP_DrawLine(RPort,Left - Length,Top + y - 1,Left + Length - 1,Top + y - 1);
  70.         LTP_DrawLine(RPort,Left - Length,Top - y,Left + Length - 1,Top - y);
  71.     }
  72. }
  73.  
  74. #endif    /* DO_TAPEDECK_KIND */
  75.